﻿
using S.Transfer.Domain;
using S.Transfer.Domain.Model;
using S.Transfer.Infrastructure.Dto;
using S.Transfer.Infrastructure.Interface.Transfer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace S.Transfer.Infrastructure.Impl.Transfer
{
    public class TransferModellRepository : BaseRepository<SheepRescission>, ITransferModellRepository
    {
        public TransferModellRepository(SqlDbContext db) : base(db)
        {

        }
        public async Task<int> AddTransferModelModelAsync(List<SheepRescission> models)
        {
            var tran = db.Database.BeginTransaction();
            int isOk = 0;
            try
            {
                //先查询
                //int[] ids = models.Select(x => x.ColumnManagementId).ToArray();
                //List<FieldModel> featureRoleMenuList = db.FieldModel.Where(x => ids.Contains(x.ColumnManagementId)).ToList();
                //批量添加
                await db.SheepRescission.AddRangeAsync(models);
                isOk += await db.SaveChangesAsync();
                await  tran.CommitAsync();
                return isOk;
            }
            catch (Exception)
            {
                 await   tran.RollbackAsync();
                throw;
            }
        }
    }
}
